﻿using System;
using System.Globalization;
using System.Windows;
using NUnit.Framework;
using ValidationFramework.WPF;

namespace ValidationFramework.Tests.WPF
{
    public class EnumToVisibilityValueConverterTest
    {

        public enum Numbers
        {
            One,
            Two,
            Three
        }
        [TestFixture]
        public class Convert
        {

            [Test]
            public void True()
            {
                var enumToVisibilityValueConverter = new EnumToVisibilityValueConverter();
				Assert.AreEqual(Visibility.Visible, enumToVisibilityValueConverter.Convert("One", typeof(Numbers), "One", CultureInfo.CurrentCulture));
            }

			//[Test]
			//[ExpectedException(typeof(ArgumentException))]
			//public void ExceptionNotEnumTrue()
			//{
			//    var enumToVisibilityValueConverter = new EnumToVisibilityValueConverter();
			//    enumToVisibilityValueConverter.Convert("One", typeof(int), "One", CultureInfo.CurrentCulture);
			//}

            [Test]
            public void NullableBool()
            {
                var enumToVisibilityValueConverter = new EnumToVisibilityValueConverter();
				Assert.AreEqual(Visibility.Visible, enumToVisibilityValueConverter.Convert("One", typeof(Numbers?), "One", CultureInfo.CurrentCulture));
            }

            [Test]
            public void False()
            {
                var enumToVisibilityValueConverter = new EnumToVisibilityValueConverter();
				Assert.AreEqual(Visibility.Collapsed, enumToVisibilityValueConverter.Convert("One", typeof(Numbers), "Two", CultureInfo.CurrentCulture));
            }

        }


        [TestFixture]
        public class ConvertBack
        {

            [Test]
            public void Simple()
            {
                var enumToVisibilityValueConverter = new EnumToVisibilityValueConverter();
                Assert.AreEqual(Numbers.Two, (Numbers)enumToVisibilityValueConverter.ConvertBack(true, typeof(Numbers), "Two", CultureInfo.CurrentCulture));
            }

            [Test]
            public void SimpleNullable()
            {
                var enumToVisibilityValueConverter = new EnumToVisibilityValueConverter();
                Assert.AreEqual(Numbers.Two, (Numbers)enumToVisibilityValueConverter.ConvertBack(true, typeof(Numbers?), "Two", CultureInfo.CurrentCulture));
            }

            [Test]
            [ExpectedException(typeof(ArgumentException))]
            public void ExceptionValueNotFound()
            {
                var enumToVisibilityValueConverter = new EnumToVisibilityValueConverter();
                enumToVisibilityValueConverter.ConvertBack(true, typeof(Numbers?), "Four", CultureInfo.CurrentCulture);
            }

            [Test]
            [ExpectedException(typeof(ArgumentException))]
            public void ExceptionInvalidType()
            {
                var enumToVisibilityValueConverter = new EnumToVisibilityValueConverter();
                enumToVisibilityValueConverter.ConvertBack(true, typeof(int), "Two", CultureInfo.CurrentCulture);
            }



        }
    }
}
